/// all the analyses in the MS and online appendix for STUDY 1 (UK) 
/// by Muradova and Beauvais 2025///
/// stata 18.5

clear
set more on
use "Study_1_UK_data_PLOSONE.dta"

/// MANIPULATION CHECK //: we check whether the treatment worked, by using the variable mc
tab mc
by treatment, sort : tabulate mc
ttest mc, by(treatment)

/// EMPATHIC CONCERN // : we check whether playing the climate game led to increased empathic concern. we had several items to capture empathy, so we create an index measure for it and then rescale it to 0-1 for an ease in interpretation. 

factor sympathy empathy concern compassion moved
alpha sympathy empathy concern compassion moved
gen empathy_index=(sympathy+empathy+concern+compassion+moved)
tab empathy_index

sum empathy_index, meanonly
gen empathy_index_res = ( empathy_index - r(min) ) / ( r(max)-r(min) )
tab empathy_index_res

/// ALL ELICITED EMOTIONS //: we rescale all these emotions for an ease in interpretation.
foreach v of var fear-helplessness {
    su `v', meanonly
    gen `v'_s = (`v' - r(min)) / (r(max) - r(min))
    label var `v'_s "`: var label `v'', scaled"
}
// we test the difference in emotional elicitation, by treatment condition. 
ttest empathy_index_res, by(treatment)
ttest fear_s, by(treatment)
ttest anger_s, by(treatment)
ttest sadness_s,by(treatment)
ttest surprise_s,by(treatment)
ttest happiness_s, by(treatment)
ttest disgust_s,by(treatment)
ttest grief_s,by (treatment)
ttest indifference_s,by(treatment)
ttest guilt_s,by(treatment)
ttest helplessness_s,by(treatment)

/// OUTCOME VARIABLES // : we run OLS regression analyses and report them in the table
/// world_climate natural_cause selfharm postfuture polp1 polp2 polp3 petition postdiscussion

ssc install estout

reg world_climate i.treatment
estimates store model1

reg natural_cause i.treatment
estimates store model2

reg selfharm i.treatment
estimates store model3

reg postfuture i.treatment
estimates store model4

reg polp1 i.treatment
estimates store model5

reg polp2 i.treatment
estimates store model6

reg polp3 i.treatment
estimates store model7

reg postdiscussion i.treatment
estimates store model8

reg petition i.treatment
estimates store model9

esttab model1 model2 model3 model4 model5 model6 model7 model8 model9 using results_table.csv, se star r2 replace

/// WITHIN-SUBJECT DISCUSSING CLIMATE CHANGE ///
fre prediscussion
fre postdiscussion
by treatment, sort : ttest prediscussion == postdiscussion

/// CAUSAL MEDIATION ANALYSES ///
* creating an index for attitudes
factor world_climate natural_cause postfuture selfharm
///self harm does not factor well
gen attitudes=(world_climate+natural_cause+postfuture)
tab attitudes

sum attitudes, meanonly
gen attitudes_s = ( attitudes - r(min) ) / ( r(max)-r(min) )
tab attitudes_s

* creating an index for polpreferences
factor polp1 polp2 polp3
gen polpreferences=(polp1+polp2+polp3)
tab polpreferences
///now rescaling it to 0-1
sum polpreferences, meanonly
gen polpreferences_s = (polpreferences - r(min) ) / ( r(max)-r(min) )
tab polpreferences_s
//search and install medeff
search medeff

// beliefs/attitudes
medeff (regress empathy_index_res treatment) (regress attitudes treatment empathy_index_res), mediate(empathy_index_res) treat(treatment) sims(1000) seed(1) 

**** policy preferences
medeff (regress empathy_index_res treatment) (regress polpreferences_s treatment empathy_index_res), mediate(empathy_index_res) treat(treatment) sims(1000) seed(1) 

**** petition 
medeff (regress empathy_index_res treatment) (regress petition treatment empathy_index_res), mediate(empathy_index_res) treat(treatment) sims(1000) seed(1) 

**** discussion, also controlling for pre treatment discussion
sum prediscussion, meanonly
gen prediscussion_s = (prediscussion - r(min) ) / ( r(max)-r(min) )
tab prediscussion_s

sum postdiscussion, meanonly
gen postdiscussion_s = (postdiscussion - r(min) ) / ( r(max)-r(min) )
tab postdiscussion_s

medeff (regress empathy_index_res treatment) (regress postdiscussion_s treatment empathy_index_res prediscussion_s), mediate(empathy_index_res) treat(treatment) sims(1000) seed(1) 


///ONLINE APPENDIX, descriptive tables
tabout gender edu party region /// 
using tablep.xls, replace style(xls) ///
font(bold) oneway c(freq col cum) f(0c 1) ///
clab(Count Col_% Cum_%) ///
npos(col) nlab(Sample) 


// ONLINE APPENDIX, variable means and sd. the var's: world_climate natural_cause postfuture selfharm polp1 polp2 polp3 petition postdiscussion
estpost summarize world_climate natural_cause postfuture selfharm polp1 polp2 polp3 petition postdiscussion
esttab, cells("mean sd") label

// ONLINE APPENDIX, models with covariates
reg world_climate i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model1

reg natural_cause i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model2

reg selfharm i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model3

reg postfuture i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model4

reg polp1 i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model5

reg polp2 i.treatment ideology_1 i.party age i.gender i.edu i.race 
estimates store model6

reg polp3 i.treatment ideology_1 i.party age i.gender i.edu i.race
estimates store model7

reg postdiscussion i.treatment ideology_1 i.party age i.gender i.edu i.race
estimates store model8

reg petition i.treatment ideology_1 i.party age i.gender i.edu i.race
estimates store model9

esttab model1 model2 model3 model4 model5 model6 model7 model8 model9 using results6_table.csv, se star r2 replace

////END

